home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / APPS / PD / EULER / PROGS / SPLINE.E < prev    next >
Encoding:
Text File  |  1991-04-19  |  1.8 KB  |  62 lines

  1. .. Test the spline function.
  2.  
  3. function test
  4. ## Demonstrates the spline functions in RMAT.
  5.     "Klicken Sie eine Anzahl von Punkten (x,y) mit der Maus an.",
  6.     "Das Programm berechnet dann den natürlichen Spline s(x) in einer",
  7.     "Variablen durch diese Punkte, sowie das Interpolationspolynom.",
  8.     "(Bitte Taste drücken)", wait(180);
  9.     ""
  10.     setplot(-1.1,1.1,-1.1,1.1); plot(-1.1,-1.1);
  11.     xgrid(-1:0.5:1); ygrid(-1:0.5:1); hold on;
  12.     title("Klicken Sie die Punkte mit der Maus an. Ende -> Hier! <-");
  13.     t=zeros(1,0); s=t; n=0;
  14.     repeat;
  15.         m=mouse(); if abs(m(1))>1.1 || abs(m(2))>1.1; break; endif;
  16.         t=t|m(1); s=s|m(2);
  17.         n=n+1;
  18.         mark([m(1),m(1)],[m(2),m(2)]);
  19.     end;
  20.     {t,i}=sort(t); s=s(i);
  21.     sp=spline(t,s); x=linspace(min(t),max(t),n*10);
  22.     plot(x,splineval(t,s,sp,x));
  23.     color(2); plot(x,interpval(t,interp(t,s),x)); color(1);
  24.     wait(180);
  25.     hold off;
  26.     
  27.     return 0;
  28. endfunction
  29.  
  30. function test2
  31. ## Demonstrates the spline functions in RMAT.
  32.     "Klicken Sie eine Anzahl von Punkten (x,y) mit der Maus an.",
  33.     "Das Programm berechnet dann den natürlichen Spline s(x,y) in zwei",
  34.     "Variablen durch diese Punkte, sowie das Interpolationspolynom.",
  35.     "(Bitte Taste drücken)", wait(180);
  36.     ""
  37.     setplot(-1.1,1.1,-1.1,1.1); plot(-1.1,-1.1);
  38.     xgrid(-1:0.5:1); ygrid(-1:0.5:1); hold on;
  39.     title("Klicken Sie die Punkte mit der Maus an. Ende -> Hier! <-");
  40.     t=zeros(1,0); s=t; n=0;
  41.     repeat;
  42.         m=mouse(); if abs(m(1))>1.1 || abs(m(2))>1.1; break; endif;
  43.         t=t|m(1); s=s|m(2);
  44.         n=n+1;
  45.         mark([m(1),m(1)],[m(2),m(2)]);
  46.     end;
  47.     spt=spline(1:n,t); sps=spline(1:n,s);
  48.     x=linspace(1,n,600);
  49.     plot(splineval(1:n,t,spt,x),splineval(1:n,s,sps,x));
  50.     color(2);
  51.     plot(interpval(1:n,interp(1:n,t),x),interpval(1:n,interp(1:n,s),x));
  52.     color(1);
  53.     wait(180);
  54.     hold off;
  55.     
  56.     return 0;
  57. endfunction
  58.  
  59.  
  60. test(); test2();
  61.  
  62.